<template>
  <div>
    <!-- 面包屑导航 S-->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>商品管理</el-breadcrumb-item>
      <el-breadcrumb-item>数据统计</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 面包屑导航 E-->

    <el-card class="box-card">
      <div id="main"></div>
    </el-card>
  </div>
</template>

<script>
import * as echarts from 'echarts'
import { getStatistics } from '@/api/statistics.js'
export default {
  data () {
    return {

    }
  },

  created () {

  },

  mounted () {
    this.initEcharts()
  },
  methods: {
    async initEcharts () {
      const myChart = echarts.init(document.getElementById('main'))
      // 获取图标数据
      const { data: res } = await getStatistics()
      // 设置俩侧留白
      res.data.xAxis[0].boundaryGap = false
      // 添加鼠标经过效果
      res.data.tooltip = {
        trigger: 'axis',
        axisPointer: {
          type: 'cross',
          label: {
            backgroundColor: '#6a7985'
          }
        }
      }
      // 绘制图表
      myChart.setOption(res.data)
    }
  }
}
</script>

<style scoped lang='less'>
#main {
  width: 100%;
  height: 500px;
}
</style>
